package com.example.websockettest.webSocket.utils;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

public class ScoringSystem {
    public static double jaccardSimilarity(String s1, String s2) {
        Set<String> set1 = new HashSet<>(Arrays.asList(s1.split("")));
        Set<String> set2 = new HashSet<>(Arrays.asList(s2.split("")));
        Set<String> intersection = new HashSet<>(set1);
        intersection.retainAll(set2);
        Set<String> union = new HashSet<>(set1);
        union.addAll(set2);
        return (double) intersection.size() / union.size();
    }



   /* public static void main(String[] args) {
        String str1 = "Hello world!And I think you guys are very great";
        String str2 = "Hollo wo!And I think you guy are very great";
        double similarity = jaccardSimilarity(str1, str2);
        System.out.println("Jaccard similarity: " + similarity);
    }*/
}
